package com.woniuxy.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class ResponseData<T> {
    private Integer code;
    private T data;
    private String msg;

    //给无参的使用
    public ResponseData ok(){
        return new ResponseData(ResponseEnum.OK.getCode(),
                null,
                ResponseEnum.OK.getMsg());
    }
    //给带参的使用
    public ResponseData ok(T data){
        return new ResponseData(ResponseEnum.OK.getCode(),data,ResponseEnum.OK.getMsg());
    }

//    失败的构造方法
    public  ResponseData fail(ResponseEnum responseEnum){
        return new ResponseData(responseEnum.getCode(),null,responseEnum.getMsg());
    }



}
